package com.tuling.plugins;

import org.apache.ibatis.executor.parameter.ParameterHandler;
import org.apache.ibatis.executor.statement.StatementHandler;
import org.apache.ibatis.plugin.*;
import org.apache.ibatis.session.ResultHandler;

import java.sql.PreparedStatement;
import java.sql.Statement;
import java.util.Properties;

/***
 * @Author 徐庶   QQ:1092002729
 * @Slogan 致敬大师，致敬未来的你
 */
@Intercepts({
        @Signature(type = StatementHandler.class, method = "query", args = {Statement.class, ResultHandler.class})
})
public class MyStatementHandlerInterceptor implements Interceptor {

    @Override
    public Object intercept(Invocation invocation) throws Throwable {
        System.out.println("MyStatementHandlerInterceptor 拦截 StatementHandler#query ");
        Object[] args = invocation.getArgs();
        return invocation.proceed();
    }


    // 加载的时候调用， 设置属性初始化
    @Override
    public void setProperties(Properties properties) {
        System.out.println("MyStatementHandlerInterceptor setProperties()......");
    }
}